package com.foton.lotterydomain.award.service.goods.impl;

import com.foton.lotterycommon.common.Constants;
import com.foton.lotterydomain.award.model.req.GoodsReq;
import com.foton.lotterydomain.award.model.res.DistributionRes;
import com.foton.lotterydomain.award.service.goods.IDistributionBase;
import com.foton.lotterydomain.award.service.goods.IDistributionGoods;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Author RenPu
 * @Date 2023/11/25 15:56
 * @Version 1.0
 * @Description: 兑换码 发奖的业务实现层
 **/

@Slf4j
@Component
public class RedeemCodeGoods extends IDistributionBase implements IDistributionGoods {


    @Override
    public DistributionRes doDistribution(GoodsReq req) {
        // 模拟调用优惠券发放接口
        log.info("模拟调用【兑换码奖品】发放接口 uId：{} awardContent：{}", req.getuId(), req.getAwardContent());

        //更新用户领奖结果
        super.updateUserAwardState(req.getuId(), req.getOrderId()
                , req.getAwardId(), Constants.AwardState.SUCCESS.getCode(), Constants.AwardState.SUCCESS.getInfo());

        return new DistributionRes(req.getuId(), Constants.AwardState.SUCCESS.getCode(), Constants.AwardState.SUCCESS.getInfo());
    }

    @Override
    public Integer getDistributionGoodsName() {
        return Constants.AwardType.RedeemCodeGoods.getCode();
    }
}
